/*!
 * Copyright (c) 2021 Qtclass Open Source Team. All rights reserved.
 * SPDX-License-Identifier: LGPL-3.0
 *
 * Authors               Contact
 * canopen               canopensrc@163.com
 */
#ifndef NETEASYBANNER_H
#define NETEASYBANNER_H

#include <QList>
#include <QParallelAnimationGroup>
#include <QPixmap>
#include <QPropertyAnimation>
#include <QWidget>

enum emAnimationType {
    UnKnow = -1,
    Next = 0,
    Prev = 1,
    Jump,
};

class QNetEasyBanner : public QWidget
{
    Q_OBJECT

  public:
    QNetEasyBanner(QWidget *parent);
    ~QNetEasyBanner();

  public:
    void addImage(const QString &image);

  public slots:
    void onNext();
    void onPrev();
    void onJump(int index);

  protected:
    void paintEvent(QPaintEvent *event);

  private:
    void drawLeft(QPainter *painter);
    void drawCenter(QPainter *painter);
    void drawRight(QPainter *painter);
    QImage getGrayImage(const QImage &image);

  private slots:
    void slot_ValueChanged(const QVariant &value);
    void slot_finished();

  private:
    QStringList x_imageList;
    int x_index;
    bool x_isAnimation;
    QParallelAnimationGroup *x_pAnimationGroup;
    QPropertyAnimation *x_pLeftAnimation;
    QPropertyAnimation *x_pCenterAnimation;
    QPropertyAnimation *x_pRightAnimation;
    emAnimationType x_animationType;

    QRect x_leftRect, x_centerRect, x_rightRect;
};

#endif // NETEASYBANNER_H
